<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/13
  Time: 16:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>展示当前入库单号的数据</title>
</head>
<body>
        <br>
        <div class="container" style="width:1000px;height:700px;border: black 2px solid">
            <div class="row">
                <div>
                    <span style="color:dodgerblue"><strong>您正在做的业务是：库存管理--入库管理--入库查询</strong></span>
                    <br><br>
                    <button onclick="outqueryByGatherid()" class="btn btn-default">返回</button>
                    <input type="hidden" id="queryBygahtergatheridshowid">
                </div>
            </div>
            <div class="row">
                <div class="col-md-offset-5"><h1>入库单</h1></div>
            </div>
            <br>
            <div class="row">
                <div class="col-md-6">
                    <table>
                        <tr>
                            <td>入库单编号:</td>
                            <td><input  id="gatherIdqueryshow" type="text" readonly style="outline: none;border: none" ></td>
                        </tr>
                        <tr>
                            <td>入库理由:</td>
                            <td><input id="reasonexactqueryshow" type="text" readonly style="outline: none;border: none" ></td>
                        </tr>
                    </table>
                </div>
                <div class="col-md-6">
                    <table>
                        <tr>
                            <td>入库详情理由:</td>
                            <td><input id="reasonqueryshow" type="text" readonly style="outline: none;border: none" ></td>
                        </tr>
                    </table>
                </div>
            </div>
            <br>
            <div style="height:45%;">
                <table id="queryBygahtergatheridshowtab">

                </table>
            </div>
            <div class="row">
                <div class="col-md-6">
                    <table>
                        <tr>
                            <td>应入库总数量:</td>
                            <td><input type="text" id="amountSumqueryshow" readonly style="outline: none;border: none" ></td>
                        </tr>
                        <tr>
                            <td>已入库总数量:</td>
                            <td><input type="text" id="amountSumqueryshow1" readonly style="outline: none;border: none" ></td>
                        </tr>
                        <tr>
                            <td>复核人:</td>
                            <td><input type="text" id="checkerqueryshow" readonly style="outline: none;border: none" ></td>
                        </tr>
                    </table>
                </div>
                <div class="col-md-6">
                    <table>
                        <tr>
                            <td>应入库总金额:</td>
                            <td><input type="text" id="costPriceSumqueryshow" readonly style="outline: none;border: none" ></td>
                        </tr>
                        <tr>
                            <td>已入库总金额:</td>
                            <td><input type="text" id="costPriceSumqueryshow1" readonly style="outline: none;border: none" ></td>
                        </tr>
                        <tr>
                            <td>复核时间:</td>
                            <td><input type="text" id="checkTimequeryshow" readonly style="outline: none;border: none" ></td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
        <!--查询产品模态框-->
        <div  class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="queryBygahtergatherdateilsidshowmodal">
            <div class="modal-dialog modal-lg">
                <div class="modal-content" id="queryBygahtergatherdateilsidshowmodalson">

                </div>
            </div>
        </div>
        <script>
            var gatherIdqueryshowss;
            function outqueryByGatherid(){
                $("#tab1").addTabs("入库查询", "", "queryallwarehousing.jsp",true);
                $("#tab1").closeTabs("入库单查询")
            }
            //加载数据
            $(function () {
                $("#queryBygahtergatheridshowtab").bootstrapTable({
                    contentType: "application/x-www-form-urlencoded", //如果用tomcat就要写这个
                    striped: true,//是否显示隔行变色
                    cache: false,//是否缓存
                    pagination: false,//是否显示分页
                    sortable: false,//是否显示排序
                    clickToSelect: true,//是否启用点击选中行
                    uniqueId:"id",//每一行的唯一标识，一般为主键列,
                    columns:[
                        {
                            field:"productName",
                            title:"产品名称",
                        },
                        {
                            field:"productId",
                            title:"产品编号",
                        },
                        {
                            field:"gatheredAmount",
                            title:"应入库数量",
                        },
                        {
                            field:"gatheredAmount",
                            title:"已入库数量",
                            formatter:function (value,row,index) {
                                if(row.gatherTag=="K002-3"){
                                    return row.gatheredAmount;
                                }else {
                                    return "0";
                                }
                            }
                        },
                        {
                            field:"subtotal",
                            title:"应入库小计(元)",
                        },
                        {
                            field:"subtotal",
                            title:"已入库小计(元)",
                            formatter:function (value,row,index) {
                                if(row.gatherTag=="K002-3"){
                                    return row.subtotal;
                                }else {
                                    return "0";
                                }
                            }
                        },
                        {
                            field:"",
                            title:"查询",
                            formatter:function (value,row,index) {
                                return "<a onclick='dispathchgathermodalsbyproductId("+row.productId+")'>查询</a>"
                            }
                        },
                    ]
                })
            })
            //加载数据
            $(function () {
                //获取gatherid
                var gatherId='${param.gatherId}'
                $.post("queryByGatherGatherdetailswarhousing.action",{"gatherId":gatherId},function (data) {
                    //赋值
                    //入库单编号
                    $("#gatherIdqueryshow").val(data.gatherId);
                    gatherIdqueryshowss=data.gatherId
                    //入库理由
                    $("#reasonexactqueryshow").val(data.reasonexact)
                    //入库详情理由
                    $("#reasonqueryshow").val(data.reason)
                    //应入库总件数
                    $("#amountSumqueryshow").val(data.amountSum)
                    //已经入库总件数
                    if(data.gatherTag!="K002-4"){
                        $("#amountSumqueryshow1").val(0)
                    }else {
                        $("#amountSumqueryshow1").val(data.amountSum)
                    }
                    //复核人
                    $("#checkerqueryshow").val(data.checker)
                    //入库总成本
                    $("#costPriceSumqueryshow").val(data.costPriceSum)

                    //入库总成本
                    if(data.gatherTag!="K002-4"){
                        $("#costPriceSumqueryshow1").val(0)
                    }else {
                        $("#costPriceSumqueryshow1").val(data.costPriceSum)
                    }
                    //复核时间
                    $("#checkTimequeryshow").val(data.checkTime)

                    //id
                    $("#queryBygahtergatheridshowid").val(data.id)
                    //入库明细表数据
                    var gatherDetailss=data.gatherDetails;
                    var arr=[];
                    for(var i=0;i<gatherDetailss.length;i++){
                        arr.push(gatherDetailss[i])
                    }
                    console.log(arr)
                    //添加到表格中
                    $("#queryBygahtergatheridshowtab").bootstrapTable("append",arr);
                },"json")
            })
            
            //根据当前库存的产品查询
            function dispathchgathermodalsbyproductId(productId) {
                $("#queryBygahtergatherdateilsidshowmodalson").load("queryBygahtergatherdateildidshowmodal.jsp",{"productId":productId,"gatherIdqueryshowss":gatherIdqueryshowss,"id":$("#queryBygahtergatheridshowid").val(),"checkTimequeryshow":$("#checkTimequeryshow").val()})
                $("#queryBygahtergatherdateilsidshowmodal").modal("show")
            }
        </script>
</body>
</html>
